<?php


namespace api\zmt\controller;


use api\zmt\model\RegistrationModel;
use cmf\controller\RestBaseController;

class loginController extends RestBaseController
{
    public function login(){
        $data = input('post.');
        $mobile = RegistrationModel::where('mobile',$data['mobile'])->find();
        if (!$mobile){
            return error('该账户不存在');
        }else{
            $password= md5($data['password'].$mobile['salt']) == $mobile['password'];
            if (!$password){
                return  error('密码错误');
            }else{
                return  success('登录成功', ['token' => singToken($mobile['id'],$mobile['mobile'])]);
            }
        }
    }
}